import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import { systemid, productid } from '../../atom/config';
import doc_code from '@dfeidao/atom-nodejs/msg/doc-code';
import operate from '@dfeidao/atom-nodejs/db/operate';
interface Message {
	plan_list_name: string,
	plan_type_no: string,
	plan_type_name: string,
	plan_cla_attr_no: string,
	plan_cla_attr_name: string,
	plan_list_depict: string,
	plan_list_status: string,

	// cookie: {
	// 	uk: string;
	// 	[key: string]: string
	// };
	// urls: {
	// 	base: string;
	// 	origin: string;
	// 	url: string;
	// };
	// query: {};
	// params: {};
	// headers: {};
	// captcha: string;
}

// interface IWebResult {
// 	data: unknown;
// 	cookie?: {
// 		[name: string]: string;
// 	} | null;
// 	content_type?: string;
// 	headers?: {
// 		[key: string]: string[];
// 	};
// 	attachment?: string;
// 	redirect?: string;
// 	status_code?: number;
// }

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
	log('Service begin path:e:\王举\学习文件\飞道工作文件\测试项目\kh\src\wangju\zj-000004\s003,action_id:' + action_id);

	const { result: code } = await doc_code(action_id, session_id, systemid, 'BM0014447', '', 1);
	const { exec, insert } = operate(action_id, session_id, systemid);
	// 插入数据
	insert('plan_list', {
		plan_list_no: code,
		plan_list_name: message.plan_list_name,
		plan_type_no: message.plan_type_no,
		plan_type_name: message.plan_type_name,
		plan_cla_attr_no: message.plan_cla_attr_no,
		plan_cla_attr_name: message.plan_cla_attr_name,
		plan_list_depict: message.plan_list_depict,
		plan_list_status: "90",
		productid

	});

	const res = await exec();


	log('Service end path:e:\王举\学习文件\飞道工作文件\测试项目\kh\src\wangju\zj-000004\s003,action_id:' + action_id);
	return res;
}
